<div id=results>
<?php echo $this->Session->flash('sr'); ?>
<?php if (isset($results) && !empty($results)) : ?>
<?php 
	$this->Paginator->options(array(
    															'update' => '#results',
    															'evalScripts' => true
    														));
?>
<h3> Search Results</h3>

<table id="list">
<tr class="head">
			<th><?php echo $this->Paginator->sort('Application Id','id');?></th>
			<th><?php echo $this->Paginator->sort('Last Name, First Name','lastname');?></th>
			<th><?php echo $this->Paginator->sort('Primary Interest Area (other area)', 'area_1');?></th>
			<th><?php echo $this->Paginator->sort('Primary Faculty (other faculty)', 'faculty_1');?></th>
			<th><?php echo $this->Paginator->sort('Primary Research Interest (other research interest)', 
																						'res_area_1');?></th>
</tr>
<?php
	$i = 1;
	foreach ($results as $app):
		$class = NULL;
		if ($i++ % 2)
			$class = ' class="odd"';
		else 
			$class = ' class="even"';
?>
<tr<?php echo $class;?>>
		<td><?php echo $app['Application']['id'] ?></td>
		<td><?php echo $app['Application']['lastname'] ?>, <?php echo $app['Application']['firstname'] ?></td>
		<td>
			<?php echo $app['Studyinterest']['area_1'] ?> 
			(<?php echo $app['Studyinterest']['area_2'] ?>,
			<?php echo $app['Studyinterest']['area_3'] ?>,
			<?php echo $app['Studyinterest']['area_4'] ?>)
		</td>
		<td>
			<?php echo $app['Studyinterest']['faculty_1'] ?> 
			(<?php echo $app['Studyinterest']['faculty_2'] ?>,
			<?php echo $app['Studyinterest']['faculty_3'] ?>,
			<?php echo $app['Studyinterest']['faculty_4'] ?>)
		</td>
		<td>
			<?php echo $app['Studyinterest']['res_area_1'] ?> 
			(<?php echo $app['Studyinterest']['res_area_2'] ?>,
			<?php echo $app['Studyinterest']['res_area_3'] ?>,
			<?php echo $app['Studyinterest']['res_area_4'] ?>)
		</td>
</tr>
<?php endforeach; ?>
</table>
<div class="paging">

		<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	
	</div>
<?php endif; ?>
</div> <!--end results-->
<h3>Applicant Search</h3>
<?php echo $this->Form->create(false, array('action' => 'search')); ?>

<p>Enter information into any of the following fields. 
	Searching by area, interest, and faculty name will return results when applicants have
	indicated the search criteria in any of their 4 area, interest, or faculty fields.</p>

<?php echo $this->Form->input('Search.name', array('Label' => 'name')); ?>
<div class="input">
	<label> OR </label>
</div>
<?php echo $this->Form->input('Search.email', array( 'Label' => 'Email')); ?>
<div class="input">
	<label> AND </label>
</div>
<?php echo $this->Form->input('Search.area', array(
																									'label' => 'Search by area',
																									'options' => $grad_area));
?>																		
<div class="input">
	<label> AND </label>
</div>
<?php echo $this->Form->input('Search.interest', array(
																											'label' => 'Search by research interest',
																											'options' => $res_area));
?>																											
<div class="input">
	<label> AND </label>
</div>
<?php echo $this->Form->input('Search.faculty', array( 
																									'label' => 'Faculty name',
																									'options' => $faculty_list));
?>																									
<?php  echo $this->Js->submit('Go', array('update' => '#results')); ?>
<?php echo $this->Form->end(); ?>
<?php echo $this->element('sql_dump'); ?>